import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/login",
    //路由懒加载
    component: () => import("@/views/login/LoginView"),
  },
  {
    path: "/",
    // name: 'layout', // 如果父路由有默认子路由，那它的 name 没有意义
    component: () => import("@/views/layout/LayoutView"),
    children: [
      {
        path: "/home", // 默认子路由，只能有1个
        name: "home",
        component: () => import("@/views/home/HomeView"),
      },
      {
        path: "/question",
        name: "question",
        component: () => import("@/views/question/QuestionView"),
      },
      {
        path: "/video",
        name: "video",
        component: () => import("@/views/video/VideoView"),
      },
      {
        path: "/my",
        name: "my",
        component: () => import("@/views/my/MyView"),
      },
    ],
  },
  {
    path: "/search",
    component: () => import("@/views/search/SearchView"),
  },
  {
    path: "/article/:articleId",
    component: () => import("@/views/article/ArticleView"),
    //开启props 接收路由参数
    props: true,
  },
  {
    path: "/useredit",
    component: () => import("@/views/my/UserEdit"),
  },
  {
    path: "/chatView",
    component: () => import("@/views/my/chatView"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
